unit uniEnemyAircraft_Tank;

interface

uses
  uniEnemyAircraft,
  Classes;

type
  { EnemyAircraft_Tank }

  EnemyAircraft_Tank = class(EnemyAircraft)
  public
    constructor Create(et: EnemyType; p: array of Single; randFact: Single = 1.0);
    destructor Destroy; override;

    procedure update;override;
    procedure init; overload;override;
    procedure init(p: array of Single; randFact: Single = 1.0); overload;override;
    procedure move;override;
  end;


implementation

uses
  uniConfig,
  uniGlobal;

{ EnemyAircraft_Tank }

constructor EnemyAircraft_Tank.Create(et: EnemyType; p: array of Single; randFact: Single);
begin
  inherited Create(et, p, randFact);
  init(p, randFact);
end;

destructor EnemyAircraft_Tank.Destroy;
begin
  inherited;
end;

procedure EnemyAircraft_Tank.init;
begin
  inherited init;
end;

procedure EnemyAircraft_Tank.init(p: array of Single; randFact: Single);
begin
  inherited init(p, randFact);

  damage := -2000.0 * uniGlobal.gameSkill;
  baseDamage := -2000.0 * uniGlobal.gameSkill;
  size[0] := 1.9;
  size[1] := 2.1;
  collisionMove := 0.1;
  vel[1] := 0.03;
end;

procedure EnemyAircraft_Tank.move;
var
  _config: Config;
  hpos: PSingle;
  diff: array[0..1] of Single;
  v1: Single;
begin
  _config := uniConfig.instance;

  if Boolean(target) then
    hpos := target.getPos
  else
    hpos := @pos;
  //float	diff[2] := { hpos[0]-pos[0], hpos[1]-pos[1] };
  diff[0] := hpos^ - pos[0]; Inc(hpos);
  diff[1] := hpos^ - pos[1];
  //float	v1;

  if (Abs(diff[0]) > 8.0) then
    v1 := 0.04
  else
    v1 := 0.04 * (Abs(diff[0]) / 8.0);
  vel[1] := 0.99 * vel[1] + 0.01 * v1;

  if (pos[1] < -3.0) then
  begin
    vel[1] := -0.1;
  end
  else
  begin
    if (pos[1] < 0.0) then vel[1] := vel[1] * 0.99;
  end;

  if (pos[0] < 0.0) then
    pos[0] := uniGlobal.speedAdj * (0.998 * pos[0] + 0.002 * (-_config.screenBoundX + 2.85))
  else
    pos[0] := uniGlobal.speedAdj * (0.998 * pos[0] + 0.002 * (_config.screenBoundX - 2.85));

  case Round(age / 50) mod 8 of
    2: pos[1] := pos[1] + uniGlobal.speedAdj * 0.05;
  else
    pos[1] := pos[1] - uniGlobal.speedAdj * vel[1];
  end;

  if (pos[0] < -_config.screenBoundX) then pos[0] := -_config.screenBoundX;
  if (pos[0] > _config.screenBoundX) then pos[0] := _config.screenBoundX;
end;

procedure EnemyAircraft_Tank.update;
begin

end;

end.

